package com.haixinga.commbiz.mgr.utils;

import com.haixinga.commbiz.commons.utils.SpringBeansUtil;
import com.haixinga.commbiz.commons.vo.OssConfigVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 参数获取工具
 **/

@Component
public class MgrPropKit {

    @Value("${isys.oss.key-id}")
    private String ossKeyId;

    @Value("${isys.oss.key-secret}")
    private String ossKeySecret;

    @Value("${isys.oss.bucket-name}")
    private String ossBucketName;

    @Value("${isys.oss.endpoint}")
    private String ossEndpoint;

    @Value("${isys.oss.expire-time}")
    private Long ossExpireTime;

    @Value("${isys.oss.max-size}")
    private Long ossMaxSize;


    /** 存放静态对象 **/
    private static MgrPropKit staticBean = null;
    private static synchronized MgrPropKit getStaticBean(){
        if(staticBean == null){
            staticBean = SpringBeansUtil.getBean(MgrPropKit.class);
        }
        return staticBean;
    }

    /** 对外提供static的get函数 */

    public static OssConfigVO getOssConfig() {

        return new OssConfigVO(
                getStaticBean().ossKeyId,
                getStaticBean().ossKeySecret,
                getStaticBean().ossBucketName,
                getStaticBean().ossEndpoint,
                getStaticBean().ossExpireTime,
                getStaticBean().ossMaxSize
        );
    }
}
